home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 3_0 / COPYFILE / XCMDGLUE.C < prev   
Text File  |  1989-05-16  |  20KB  |  696 lines

  1. /*
  2.     XCmdGlue.inc.c  Definitions for calling all standard 
  3.     HyperCard callback routines from C.  Include "HyperXCmd.h" 
  4.     before your program and this file after it.  Arguments are slightly 
  5.     different from Pascal.  The first argument is always a pointer to
  6.     the parameter block that HyperCard passed to the XCMD or XFCN.
  7.     This file derived from the Pascal interface, which is included as
  8.     comments.
  9.     
  10.       ⌐Apple Computer, Inc. 1987
  11.     All Rights Reserved.
  12.  
  13.     See CFlash.C for an example of how to include this module in your 
  14.     C program.
  15. */
  16.  
  17.  
  18. /*  Do a simple jump subroutine to a procedure with no arguments.  The 
  19.     address of the procedure is in the argument.   Declared above in 
  20.     HyperXCmd.h.  */
  21. /*    typedef void (*MyProcPtr) ();  */
  22. /*  PROCEDURE DoJsr(addr: ProcPtr); INLINE $205F,$4E90;  */
  23.  
  24.  
  25. pascal void SendCardMessage(paramPtr,msg)
  26.     XCmdBlockPtr    paramPtr;    StringPtr    msg;
  27.     /* Send a HyperCard message (a command with arguments) to the current card.
  28.        msg is a pointer to a Pascal format string.  */
  29. {
  30.     paramPtr->inArgs[0] = (long)msg;
  31.     paramPtr->request = xreqSendCardMessage;
  32.     (*((MyProcPtr) paramPtr->entryPoint))();
  33. }
  34. /*    PROCEDURE SendCardMessage(msg: Str255);
  35. BEGIN
  36.   WITH paramPtr^ DO
  37.     BEGIN
  38.       inArgs[1] := ORD(@msg);
  39.       request := xreqSendCardMessage;
  40.       DoJsr(entryPoint);
  41.     END;
  42. END;   */
  43.  
  44.  
  45.  
  46. pascal Handle EvalExpr(paramPtr,expr)
  47.     XCmdBlockPtr    paramPtr;    StringPtr    expr;
  48.     /* Evaluate a HyperCard expression and return the answer.  The answer is
  49.        a handle to a zero-terminated string. */
  50. {
  51.     paramPtr->inArgs[0] = (long)expr;
  52.     paramPtr->request = xreqEvalExpr;
  53.     (*((MyProcPtr) paramPtr->entryPoint))();
  54.     return (Handle)paramPtr->outArgs[0];
  55. }
  56. /*  FUNCTION EvalExpr(expr: Str255): Handle;
  57. BEGIN
  58.   WITH paramPtr^ DO
  59.     BEGIN
  60.       inArgs[1] := ORD(@expr);
  61.       request := xreqEvalExpr;
  62.       DoJsr(entryPoint);
  63.       EvalExpr := Handle(outArgs[1]);
  64.     END;
  65. END;   */
  66.  
  67.  
  68. pascal long StringLength(paramPtr,strPtr)
  69.     XCmdBlockPtr    paramPtr;    StringPtr    strPtr;
  70. /* Count the characters from where strPtr points until the next zero byte. 
  71.    Does not count the zero itself.  strPtr must be a zero-terminated string. */
  72. {
  73.     paramPtr->inArgs[0] = (long)strPtr;
  74.     paramPtr->request = xreqStringLength;
  75.     (*((MyProcPtr) paramPtr->entryPoint))();
  76.     return (long)paramPtr->outArgs[0];
  77. }
  78. /*    FUNCTION StringLength(strPtr: Ptr): LongInt;
  79. BEGIN
  80.   WITH paramPtr^ DO
  81.     BEGIN
  82.       inArgs[1] := ORD(strPtr);
  83.       request := xreqStringLength;
  84.       DoJsr(entryPoint);
  85.       StringLength := outArgs[1];
  86.     END;
  87. END;   */
  88.  
  89.  
  90. pascal Ptr StringMatch(paramPtr,pattern,target)
  91.     XCmdBlockPtr    paramPtr;    StringPtr    pattern;    Ptr    target;
  92. /* Perform case-insensitive match looking for pattern anywhere in
  93.    target, returning a pointer to first character of the first match,
  94.    in target or NIL if no match found.  pattern is a Pascal string,
  95.    and target is a zero-terminated string. */
  96. {
  97.     paramPtr->inArgs[0] = (long)pattern;
  98.     paramPtr->inArgs[1] = (long)target;
  99.     paramPtr->request = xreqStringMatch;
  100.     (*((MyProcPtr) paramPtr->entryPoint))();
  101.     return (Ptr)paramPtr->outArgs[0];
  102. }
  103. /*    FUNCTION StringMatch(pattern: Str255; target: Ptr): Ptr;
  104. BEGIN
  105.   WITH paramPtr^ DO
  106.     BEGIN
  107.       inArgs[1] := ORD(@pattern);
  108.       inArgs[2] := ORD(target);
  109.       request := xreqStringMatch;
  110.       DoJsr(entryPoint);
  111.       StringMatch := Ptr(outArgs[1]);
  112.     END;
  113. END;   */
  114.  
  115.  
  116. pascal void ZeroBytes(paramPtr,dstPtr,longCount)
  117.     XCmdBlockPtr    paramPtr;    Ptr    dstPtr;    long    longCount;
  118. /* Write zeros into memory starting at destPtr and going for longCount 
  119.    number of bytes. */
  120. {
  121.     paramPtr->inArgs[0] = (long)dstPtr;
  122.     paramPtr->inArgs[1] = longCount;
  123.     paramPtr->request = xreqZeroBytes;
  124.     (*((MyProcPtr) paramPtr->entryPoint))();
  125. }
  126. /*    PROCEDURE ZeroBytes(dstPtr: Ptr; longCount: LongInt);
  127. BEGIN
  128.   WITH paramPtr^ DO
  129.     BEGIN
  130.       inArgs[1] := ORD(dstPtr);
  131.       inArgs[2] := longCount;
  132.       request := xreqZeroBytes;
  133.       DoJsr(entryPoint);
  134.     END;
  135. END;   */
  136.  
  137.  
  138. pascal Handle PasToZero(paramPtr,pasStr)
  139.     XCmdBlockPtr    paramPtr;    StringPtr    pasStr;
  140. /* Convert a Pascal string to a zero-terminated string.  Returns a handle
  141.    to a new zero-terminated string.  The caller must dispose the handle.
  142.    You'll need to do this for any result or argument you send from 
  143.    your XCMD to HyperTalk. */
  144. {
  145.     paramPtr->inArgs[0] = (long)pasStr;
  146.     paramPtr->request = xreqPasToZero;
  147.     (*((MyProcPtr) paramPtr->entryPoint))();
  148.     return (Handle)paramPtr->outArgs[0];
  149. }
  150. /*    FUNCTION PasToZero(str: Str255): Handle;
  151. BEGIN
  152.   WITH paramPtr^ DO
  153.     BEGIN
  154.       inArgs[1] := ORD(@str);
  155.       request := xreqPasToZero;
  156.       DoJsr(entryPoint);
  157.       PasToZero := Handle(outArgs[1]);
  158.     END;
  159. END;   */
  160.  
  161.  
  162. pascal void ZeroToPas(paramPtr,zeroStr,pasStr)
  163.     XCmdBlockPtr    paramPtr;    char    *zeroStr;    StringPtr    pasStr;
  164. /* Fill the Pascal string with the contents of the zero-terminated
  165.    string.  You create the Pascal string and pass it in as a VAR 
  166.    parameter.  Useful for converting the arguments of any XCMD to 
  167.    Pascal strings. */
  168. {
  169.     paramPtr->inArgs[0] = (long)zeroStr;
  170.     paramPtr->inArgs[1] = (long)pasStr;
  171.     paramPtr->request = xreqZeroToPas;
  172.     (*((MyProcPtr) paramPtr->entryPoint))();
  173. }
  174. /*  PROCEDURE ZeroToPas(zeroStr: Ptr; VAR pasStr: Str255);
  175. BEGIN
  176.   WITH paramPtr^ DO
  177.     BEGIN
  178.       inArgs[1] := ORD(zeroStr);
  179.       inArgs[2] := ORD(@pasStr);
  180.       request := xreqZeroToPas;
  181.       DoJsr(entryPoint);
  182.     END;
  183. END;  */
  184.  
  185.  
  186. pascal long StrToLong(paramPtr,strPtr)
  187.     XCmdBlockPtr    paramPtr;    Str31 *    strPtr;
  188. /* Convert a string of ASCII decimal digits to an unsigned long integer. */
  189. {
  190.     paramPtr->inArgs[0] = (long)strPtr;
  191.     paramPtr->request = xreqStrToLong;
  192.     (*((MyProcPtr) paramPtr->entryPoint))();
  193.     return (long)paramPtr->outArgs[0];
  194. }
  195. /*    FUNCTION StrToLong(str: Str31): LongInt;
  196. BEGIN
  197.   WITH paramPtr^ DO
  198.     BEGIN
  199.       inArgs[1] := ORD(@str);
  200.       request := xreqStrToLong;
  201.       DoJsr(entryPoint);
  202.       StrToLong := outArgs[1];
  203.     END;
  204. END;   */
  205.  
  206.  
  207. pascal long StrToNum(paramPtr,str)
  208.     XCmdBlockPtr    paramPtr;    Str31 *     str;
  209. /* Convert a string of ASCII decimal digits to a signed long integer.
  210.    Negative sign is allowed. */
  211. {
  212.     paramPtr->inArgs[0] = (long)str;
  213.     paramPtr->request = xreqStrToNum;
  214.     (*((MyProcPtr) paramPtr->entryPoint))();
  215.     return paramPtr->outArgs[0];
  216. }
  217. /*    FUNCTION StrToNum(str: Str31): LongInt;
  218. BEGIN
  219.   WITH paramPtr^ DO
  220.     BEGIN
  221.       inArgs[1] := ORD(@str);
  222.       request := xreqStrToNum;
  223.       DoJsr(entryPoint);
  224.       StrToNum := outArgs[1];
  225.     END;
  226. END;  */
  227.  
  228.  
  229. pascal Boolean StrToBool(paramPtr,str)
  230.     XCmdBlockPtr    paramPtr;    Str31 *     str;
  231. /* Convert the Pascal strings 'true' and 'false' to booleans. */
  232. {
  233.     paramPtr->inArgs[0] = (long)str;
  234.     paramPtr->request = xreqStrToBool;
  235.     (*((MyProcPtr) paramPtr->entryPoint))();
  236.     return (Boolean)paramPtr->outArgs[0];
  237. }
  238. /*    FUNCTION StrToBool(str: Str31): BOOLEAN;
  239. BEGIN
  240.   WITH paramPtr^ DO
  241.     BEGIN
  242.       inArgs[1] := ORD(@str);
  243.       request := xreqStrToBool;
  244.       DoJsr(entryPoint);
  245.       StrToBool := BOOLEAN(outArgs[1]);
  246.     END;
  247. END;   */
  248.  
  249.  
  250. #if extended
  251. pascal void StrToExt(paramPtr,str,myext)
  252.     XCmdBlockPtr    paramPtr;    Str31 *     str;    extended *    myext;
  253.  /* Convert a string of ASCII decimal digits to an extended long integer.
  254.     Instead of returning a new extended, as Pascal does, it expects you 
  255.     to create myext and pass it in to be filled. */
  256. {
  257.     paramPtr->inArgs[0] = (long)str;
  258.     paramPtr->inArgs[1] = (long)myext;
  259.     paramPtr->request = xreqStrToExt;
  260.     (*((MyProcPtr) paramPtr->entryPoint))();
  261. }
  262. /*    FUNCTION StrToExt(str: Str31): Extended;
  263. VAR x: Extended;
  264. BEGIN
  265.   WITH paramPtr^ DO
  266.     BEGIN
  267.       inArgs[1] := ORD(@str);
  268.       inArgs[2] := ORD(@x);
  269.       request := xreqStrToExt;
  270.       DoJsr(entryPoint);
  271.       StrToExt := x;
  272.     END;
  273. END;   */
  274. #endif
  275.  
  276.  
  277. pascal void LongToStr(paramPtr,posNum,mystr)
  278.     XCmdBlockPtr    paramPtr;    long     posNum;    Str31 *    mystr;
  279.  /* Convert an unsigned long integer to a Pascal string.  Instead of 
  280.     returning a new string, as Pascal does, it expects you to 
  281.     create mystr and pass it in to be filled. */
  282. {
  283.     paramPtr->inArgs[0] = (long)posNum;
  284.     paramPtr->inArgs[1] = (long)mystr;
  285.     paramPtr->request = xreqLongToStr;
  286.     (*((MyProcPtr) paramPtr->entryPoint))();
  287. }
  288. /*    FUNCTION LongToStr(posNum: LongInt): Str31;
  289. VAR str: Str31;
  290. BEGIN
  291.   WITH paramPtr^ DO
  292.     BEGIN
  293.       inArgs[1] := posNum;
  294.       inArgs[2] := ORD(@str);
  295.       request := xreqLongToStr;
  296.       DoJsr(entryPoint);
  297.       LongToStr := str;
  298.     END;
  299. END;   */
  300.  
  301.  
  302. pascal void NumToStr(paramPtr,num,mystr)
  303.     XCmdBlockPtr    paramPtr;    long     num;    Str31 *    mystr;
  304.  /* Convert a signed long integer to a Pascal string.  Instead of 
  305.     returning a new string, as Pascal does, it expects you to 
  306.     create mystr and pass it in to be filled. */
  307. {
  308.     paramPtr->inArgs[0] = num;
  309.     paramPtr->inArgs[1] = (long)mystr;
  310.     paramPtr->request = xreqNumToStr;
  311.     (*((MyProcPtr) paramPtr->entryPoint))();
  312. }
  313. /*    FUNCTION NumToStr(num: LongInt): Str31;
  314. VAR str: Str31;
  315. BEGIN
  316.   WITH paramPtr^ DO
  317.     BEGIN
  318.       inArgs[1] := num;
  319.       inArgs[2] := ORD(@str);
  320.       request := xreqNumToStr;
  321.       DoJsr(entryPoint);
  322.       NumToStr := str;
  323.     END;
  324. END;   */
  325.  
  326.  
  327. pascal void NumToHex(paramPtr,num,nDigits,mystr)
  328.     XCmdBlockPtr    paramPtr;    long     num;
  329.     short    nDigits;            Str31 *    mystr;
  330. /* Convert an unsigned long integer to a hexadecimal number and put it
  331.    into a Pascal string.  Instead of returning a new string, as 
  332.    Pascal does, it expects you to create mystr and pass it in to be filled. */
  333. {
  334.     paramPtr->inArgs[0] = num;
  335.     paramPtr->inArgs[1] = nDigits;
  336.     paramPtr->inArgs[2] = (long)mystr;
  337.     paramPtr->request = xreqNumToHex;
  338.     (*((MyProcPtr) paramPtr->entryPoint))();
  339. }
  340. /*    FUNCTION NumToHex(num: LongInt; nDigits: INTEGER): Str31;
  341. VAR str: Str31;
  342. BEGIN
  343.   WITH paramPtr^ DO
  344.     BEGIN
  345.       inArgs[1] := num;
  346.       inArgs[2] := nDigits;
  347.       inArgs[3] := ORD(@str);
  348.       request := xreqNumToHex;
  349.       DoJsr(entryPoint);
  350.       NumToHex := str;
  351.     END;
  352. END;   */
  353.  
  354.  
  355. pascal void BoolToStr(paramPtr,bool,mystr)
  356.     XCmdBlockPtr    paramPtr;    Boolean    bool;    Str31 *    mystr;
  357.  /* Convert a boolean to 'true' or 'false'.  Instead of returning 
  358.     a new string, as Pascal does, it expects you to create mystr
  359.     and pass it in to be filled. */
  360. {
  361.     paramPtr->inArgs[0] = (long)bool;
  362.     paramPtr->inArgs[1] = (long)mystr;
  363.     paramPtr->request = xreqBoolToStr;
  364.     (*((MyProcPtr) paramPtr->entryPoint))();
  365. }
  366. /*    FUNCTION BoolToStr(bool: BOOLEAN): Str31;
  367. VAR str: Str31;
  368. BEGIN
  369.   WITH paramPtr^ DO
  370.     BEGIN
  371.       inArgs[1] := LongInt(bool);
  372.       inArgs[2] := ORD(@str);
  373.       request := xreqBoolToStr;
  374.       DoJsr(entryPoint);
  375.       BoolToStr := str;
  376.     END;
  377. END;   */
  378.  
  379.  
  380. #if extended
  381. pascal void ExtToStr(paramPtr,myext,mystr)
  382.     XCmdBlockPtr    paramPtr;    extended *    myext;    Str31 *    mystr;
  383.  /* Convert an extended long integer to decimal digits in a string.  
  384.     Instead of returning a new string, as Pascal does, it expects 
  385.     you to create mystr and pass it in to be filled. */
  386. {
  387.     paramPtr->inArgs[0] = (long)myext;
  388.     paramPtr->inArgs[1] = (long)mystr;
  389.     paramPtr->request = xreqExtToStr;
  390.     (*((MyProcPtr) paramPtr->entryPoint))();
  391. }
  392. /*    FUNCTION ExtToStr(num: Extended): Str31;
  393. VAR str: Str31;
  394. BEGIN
  395.   WITH paramPtr^ DO
  396.     BEGIN
  397.       inArgs[1] := ORD(@num);
  398.       inArgs[2] := ORD(@str);
  399.       request := xreqExtToStr;
  400.       DoJsr(entryPoint);
  401.       ExtToStr := str;
  402.     END;
  403. END;   */
  404. #endif
  405.  
  406.  
  407. pascal Handle GetGlobal(paramPtr,globName)
  408.     XCmdBlockPtr    paramPtr;    StringPtr    globName;
  409. /* Return a handle to a zero-terminated string containing the value of 
  410.    the specified HyperTalk global variable. */
  411. {
  412.     paramPtr->inArgs[0] = (long)globName;
  413.     paramPtr->request = xreqGetGlobal;
  414.     (*((MyProcPtr) paramPtr->entryPoint))();
  415.     return (Handle)paramPtr->outArgs[0];
  416. }
  417. /*    FUNCTION GetGlobal(globName: Str255): Handle;
  418. BEGIN
  419.   WITH paramPtr^ DO
  420.     BEGIN
  421.       inArgs[1] := ORD(@globName);
  422.       request := xreqGetGlobal;
  423.       DoJsr(entryPoint);
  424.       GetGlobal := Handle(outArgs[1]);
  425.     END;
  426. END;   */
  427.  
  428.  
  429. pascal void SetGlobal(paramPtr,globName,globValue)
  430.     XCmdBlockPtr    paramPtr;    StringPtr    globName;    Handle    globValue;
  431. /* Set the value of the specified HyperTalk global variable to be
  432.    the zero-terminated string in globValue.  The contents of the 
  433.    Handle are copied, so you must still dispose it afterwards.  */
  434. {
  435.     paramPtr->inArgs[0] = (long)globName;
  436.     paramPtr->inArgs[1] = (long)globValue;
  437.     paramPtr->request = xreqSetGlobal;
  438.     (*((MyProcPtr) paramPtr->entryPoint))();
  439. }
  440. /*    PROCEDURE SetGlobal(globName: Str255; globValue: Handle);
  441. BEGIN
  442.   WITH paramPtr^ DO
  443.     BEGIN
  444.       inArgs[1] := ORD(@globName);
  445.       inArgs[2] := ORD(globValue);
  446.       request := xreqSetGlobal;
  447.       DoJsr(entryPoint);
  448.     END;
  449. END;   */
  450.  
  451.  
  452. pascal Handle GetFieldByName(paramPtr,cardFieldFlag,fieldName)
  453.     XCmdBlockPtr    paramPtr;    Boolean    cardFieldFlag;
  454.     StringPtr    fieldName;
  455. /* Return a handle to a zero-terminated string containing the value of 
  456.    field fieldName on the current card.  You must dispose the handle. */
  457. {
  458.     paramPtr->inArgs[0] = (long)cardFieldFlag;
  459.     paramPtr->inArgs[1] = (long)fieldName;
  460.     paramPtr->request = xreqGetFieldByName;
  461.     (*((MyProcPtr) paramPtr->entryPoint))();
  462.     return (Handle)paramPtr->outArgs[0];
  463. }
  464. /*    FUNCTION GetFieldByName(cardFieldFlag: BOOLEAN; fieldName: Str255): Handle;
  465. BEGIN
  466.   WITH paramPtr^ DO
  467.     BEGIN
  468.       inArgs[1] := ORD(cardFieldFlag);
  469.       inArgs[2] := ORD(@fieldName);
  470.       request := xreqGetFieldByName;
  471.       DoJsr(entryPoint);
  472.       GetFieldByName := Handle(outArgs[1]);
  473.     END;
  474. END;   */
  475.  
  476.  
  477. pascal Handle GetFieldByNum(paramPtr,cardFieldFlag,fieldNum)
  478.     XCmdBlockPtr    paramPtr;    Boolean    cardFieldFlag;
  479.     short    fieldNum;
  480. /* Return a handle to a zero-terminated string containing the value of 
  481.    field fieldNum on the current card.  You must dispose the handle. */
  482. {
  483.     paramPtr->inArgs[0] = (long)cardFieldFlag;
  484.     paramPtr->inArgs[1] = fieldNum;
  485.     paramPtr->request = xreqGetFieldByNum;
  486.     (*((MyProcPtr) paramPtr->entryPoint))();
  487.     return (Handle)paramPtr->outArgs[0];
  488. }
  489. /*    FUNCTION GetFieldByNum(cardFieldFlag: BOOLEAN; fieldNum: INTEGER): Handle;
  490. BEGIN
  491.   WITH paramPtr^ DO
  492.     BEGIN
  493.       inArgs[1] := ORD(cardFieldFlag);
  494.       inArgs[2] := fieldNum;
  495.       request := xreqGetFieldByNum;
  496.       DoJsr(entryPoint);
  497.       GetFieldByNum := Handle(outArgs[1]);
  498.     END;
  499. END;   */
  500.  
  501.  
  502. pascal Handle GetFieldByID(paramPtr,cardFieldFlag,fieldID)
  503.     XCmdBlockPtr    paramPtr;    Boolean    cardFieldFlag;
  504.     short    fieldID;
  505. /* Return a handle to a zero-terminated string containing the value of 
  506.    the field whise ID is fieldID.  You must dispose the handle. */
  507. {
  508.     paramPtr->inArgs[0] = (long)cardFieldFlag;
  509.     paramPtr->inArgs[1] = fieldID;
  510.     paramPtr->request = xreqGetFieldByID;
  511.     (*((MyProcPtr) paramPtr->entryPoint))();
  512.     return (Handle)paramPtr->outArgs[0];
  513. }
  514. /*    FUNCTION GetFieldByID(cardFieldFlag: BOOLEAN; fieldID: INTEGER): Handle;
  515. BEGIN
  516.   WITH paramPtr^ DO
  517.     BEGIN
  518.       inArgs[1] := ORD(cardFieldFlag);
  519.       inArgs[2] := fieldID;
  520.       request := xreqGetFieldByID;
  521.       DoJsr(entryPoint);
  522.       GetFieldByID := Handle(outArgs[1]);
  523.     END;
  524. END;   */
  525.  
  526.  
  527. pascal void SetFieldByName(paramPtr,cardFieldFlag,fieldName,fieldVal)
  528.     XCmdBlockPtr    paramPtr;    Boolean    cardFieldFlag;
  529.     StringPtr    fieldName;    Handle    fieldVal;
  530. /* Set the value of field fieldName to be the zero-terminated string 
  531.    in fieldVal.  The contents of the Handle are copied, so you must 
  532.    still dispose it afterwards. */
  533. {
  534.     paramPtr->inArgs[0] = (long)cardFieldFlag;
  535.     paramPtr->inArgs[1] = (long)fieldName;
  536.     paramPtr->inArgs[2] = (long)fieldVal;
  537.     paramPtr->request = xreqSetFieldByName;
  538.     (*((MyProcPtr) paramPtr->entryPoint))();
  539. }
  540. /*    PROCEDURE SetFieldByName(cardFieldFlag: BOOLEAN; fieldName: Str255; fieldVal: Handle);
  541. BEGIN
  542.   WITH paramPtr^ DO
  543.     BEGIN
  544.       inArgs[1] := ORD(cardFieldFlag);
  545.       inArgs[2] := ORD(@fieldName);
  546.       inArgs[3] := ORD(fieldVal);
  547.       request := xreqSetFieldByName;
  548.       DoJsr(entryPoint);
  549.     END;
  550. END;   */
  551.  
  552.  
  553. pascal void SetFieldByNum(paramPtr,cardFieldFlag,fieldNum,fieldVal)
  554.     XCmdBlockPtr    paramPtr;    Boolean    cardFieldFlag;
  555.     short    fieldNum;            Handle    fieldVal;
  556. /* Set the value of field fieldNum to be the zero-terminated string 
  557.    in fieldVal.  The contents of the Handle are copied, so you must 
  558.    still dispose it afterwards. */
  559. {
  560.     paramPtr->inArgs[0] = (long)cardFieldFlag;
  561.     paramPtr->inArgs[1] = fieldNum;
  562.     paramPtr->inArgs[2] = (long)fieldVal;
  563.     paramPtr->request = xreqSetFieldByNum;
  564.     (*((MyProcPtr) paramPtr->entryPoint))();
  565. }
  566. /*    PROCEDURE SetFieldByNum(cardFieldFlag: BOOLEAN; fieldNum: INTEGER; fieldVal: Handle);
  567. BEGIN
  568.   WITH paramPtr^ DO
  569.     BEGIN
  570.       inArgs[1] := ORD(cardFieldFlag);
  571.       inArgs[2] := fieldNum;
  572.       inArgs[3] := ORD(fieldVal);
  573.       request := xreqSetFieldByNum;
  574.       DoJsr(entryPoint);
  575.     END;
  576. END;   */
  577.  
  578.  
  579. pascal void SetFieldByID(paramPtr,cardFieldFlag,fieldID,fieldVal)
  580.     XCmdBlockPtr    paramPtr;    Boolean    cardFieldFlag;
  581.     short    fieldID;            Handle    fieldVal;
  582. /* Set the value of the field whose ID is fieldID to be the zero-
  583.    terminated string in fieldVal.  The contents of the Handle are 
  584.    copied, so you must still dispose it afterwards. */
  585. {
  586.     paramPtr->inArgs[0] = (long)cardFieldFlag;
  587.     paramPtr->inArgs[1] = fieldID;
  588.     paramPtr->inArgs[2] = (long)fieldVal;
  589.     paramPtr->request = xreqSetFieldByID;
  590.     (*((MyProcPtr) paramPtr->entryPoint))();
  591. }
  592. /*    PROCEDURE SetFieldByID(cardFieldFlag: BOOLEAN; fieldID: INTEGER; fieldVal: Handle);
  593. BEGIN
  594.   WITH paramPtr^ DO
  595.     BEGIN
  596.       inArgs[1] := ORD(cardFieldFlag);
  597.       inArgs[2] := fieldID;
  598.       inArgs[3] := ORD(fieldVal);
  599.       request := xreqSetFieldByID;
  600.       DoJsr(entryPoint);
  601.     END;
  602. END;   */
  603.  
  604.  
  605. pascal Boolean StringEqual(paramPtr,str1,str2)
  606.     XCmdBlockPtr    paramPtr;    Str31 *     str1;    Str31 *     str2;
  607. /* Return true if the two strings have the same characters.  
  608.    Case insensitive compare of the strings. */
  609. {
  610.     paramPtr->inArgs[0] = (long)str1;
  611.     paramPtr->inArgs[1] = (long)str2;
  612.     paramPtr->request = xreqStringEqual;
  613.     (*((MyProcPtr) paramPtr->entryPoint))();
  614.     return (Boolean)paramPtr->outArgs[0];
  615. }
  616. /*    FUNCTION StringEqual(str1,str2: Str255): BOOLEAN;
  617. BEGIN
  618.   WITH paramPtr^ DO
  619.     BEGIN
  620.       inArgs[1] := ORD(@str1);
  621.       inArgs[2] := ORD(@str2);
  622.       request := xreqStringEqual;
  623.       DoJsr(entryPoint);
  624.       StringEqual := BOOLEAN(outArgs[1]);
  625.     END;
  626. END;   */
  627.  
  628.  
  629. pascal void ReturnToPas(paramPtr,zeroStr,pasStr)
  630.     XCmdBlockPtr    paramPtr;    Ptr    zeroStr;    StringPtr    pasStr;
  631. /* zeroStr points into a zero-terminated string.  Collect the 
  632.    characters from there to the next carriage Return and return 
  633.    them in the Pascal string pasStr.  If a Return is not found, 
  634.    collect chars until the end of the string. */
  635. {
  636.     paramPtr->inArgs[0] = (long)zeroStr;
  637.     paramPtr->inArgs[1] = (long)pasStr;
  638.     paramPtr->request = xreqReturnToPas;
  639.     (*((MyProcPtr) paramPtr->entryPoint))();
  640. }
  641. /*    PROCEDURE ReturnToPas(zeroStr: Ptr; VAR pasStr: Str255);
  642. BEGIN
  643.   WITH paramPtr^ DO
  644.     BEGIN
  645.       inArgs[1] := ORD(zeroStr);
  646.       inArgs[2] := ORD(@pasStr);
  647.       request := xreqReturnToPas;
  648.       DoJsr(entryPoint);
  649.     END;
  650. END;   */
  651.  
  652.  
  653. pascal void ScanToReturn(paramPtr,scanHndl)
  654.     XCmdBlockPtr    paramPtr;    Ptr *    scanHndl;
  655. /* Move the pointer scanPtr along a zero-terminated 
  656.    string until it points at a Return character
  657.    or a zero byte.  */
  658. {
  659.     paramPtr->inArgs[0] = (long)scanHndl;
  660.     paramPtr->request = xreqScanToReturn;
  661.     (*((MyProcPtr) paramPtr->entryPoint))();
  662. }
  663. /*    PROCEDURE ScanToReturn(VAR scanPtr: Ptr);
  664. BEGIN
  665.   WITH paramPtr^ DO
  666.     BEGIN
  667.       inArgs[1] := ORD(@scanPtr);
  668.       request := xreqScanToReturn;
  669.       DoJsr(entryPoint);
  670.     END;
  671. END;   */
  672.  
  673.  
  674. pascal void ScanToZero(paramPtr,scanHndl)
  675.     XCmdBlockPtr    paramPtr;    Ptr *    scanHndl;
  676. /* Move the pointer scanPtr along a zero-terminated 
  677.    string until it points at a zero byte.  */
  678. {
  679.     paramPtr->inArgs[0] = (long)scanHndl;
  680.     paramPtr->request = xreqScanToZero;
  681.     (*((MyProcPtr) paramPtr->entryPoint))();
  682. }
  683. /*    PROCEDURE ScanToZero(VAR scanPtr: Ptr);
  684. BEGIN
  685.   WITH paramPtr^ DO
  686.     BEGIN
  687.       inArgs[1] := ORD(@scanPtr);
  688.       request := xreqScanToZero;
  689.       DoJsr(entryPoint);
  690.     END;
  691. END;   */
  692.  
  693.  
  694.  
  695.  
  696.